package com.ipc.app.sheduler.impl;

import java.util.List;

import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import com.ipc.app.sheduler.IPCSheduler;
import com.ipc.app.sheduler.task.IPCTask;

public abstract class AbstractIPCSheduler implements IPCSheduler {

	private ThreadPoolTaskExecutor threadPoolTaskExecutor;

	public void onSheduler() {

		List<IPCTask> tasks = this.getTaskList();
		if (null == tasks || tasks.size() == 0) {
			return;
		}
		for (IPCTask task : tasks) {
			threadPoolTaskExecutor.execute(task);
		}
	}

	public abstract List<IPCTask> getTaskList();

	public void setThreadPoolTaskExecutor(
			ThreadPoolTaskExecutor threadPoolTaskExecutor) {
		this.threadPoolTaskExecutor = threadPoolTaskExecutor;
	}

}
